-
Notifications
You must be signed in to change notification settings - Fork 421
Log structured peer, channel and hash fields #4217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
5bae991 to
bf104c0
Compare
lightning/src/util/test_utils.rs
Outdated
| let s = format!("{:<55} {}", context, record.args); | ||
| let chan_id = record.channel_id.map(|id| format!("{}", id)); | ||
| let chan_str = chan_id.as_deref().and_then(|s| s.get(..6)).unwrap_or(""); | ||
| let s = format!("{:<55} {:<6} {}", context, chan_str, record.args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than just updating the test logger, let's instead maybe add a Display implementation for Record that includes all the relevant information? After we do that we'll need to update the one in fuzzing and IMO the docs on the logger to make clear that we intend to not include redundant information in the human-readable part of the log record (and that they absolutely need to include it if they want useful logs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Display added and docs updated.
bf104c0 to
9491fa7
Compare
44dec3f to
2f6b50a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4217 +/- ##
==========================================
- Coverage 89.36% 89.36% -0.01%
==========================================
Files 180 180
Lines 138369 138283 -86
Branches 138369 138283 -86
==========================================
- Hits 123652 123574 -78
+ Misses 12114 12103 -11
- Partials 2603 2606 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2f6b50a to
f2483eb
Compare
| &self, _sender: PublicKey, _peers: Vec<PublicKey>, destination: Destination, | ||
| ) -> Result<OnionMessagePath, ()> { | ||
| Ok(OnionMessagePath { intermediate_nodes: vec![], destination, first_node_addresses: vec![] }) | ||
| Ok(OnionMessagePath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf rustfmt? This wasn't even changed 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
61b1780 to
3506f92
Compare
TheBlueMatt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, needs rebase though.
As a preparatory step for unifying test log output.
Makes sure that 4 and 5 character log levels line up.
Now that we have Display implemented on Record, the various test logger implementations can make use of that.
3506f92 to
2febae0
Compare
|
Rebased |
2febae0 to
e76d564
Compare
e76d564 to
73ea256
Compare
valentinewallace
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer putting the peer and payment hash at the end of the log, at least in test output. I work on a laptop somewhat regularly and this change pushes the actual log content very far to the side, particularly since the payment_hash field doesn't seem to be set the vast majority of the time.
We could also maybe do this in addition:
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index 643c1825f..a0cd881f1 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -4360,7 +4360,7 @@ pub fn create_chanmon_cfgs_with_legacy_keys(
let tx_broadcaster = test_utils::TestBroadcaster::new(Network::Testnet);
let fee_estimator = test_utils::TestFeeEstimator::new(253);
let chain_source = test_utils::TestChainSource::new(Network::Testnet);
- let logger = test_utils::TestLogger::with_id(format!("node {}", i));
+ let logger = test_utils::TestLogger::with_id(format!("n{}", i));
let persister = test_utils::TestPersister::new();
let seed = [i as u8; 32];
let keys_manager = if predefined_keys_ids.is_some() {
diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs
index 5f408a9e8..d414b980f 100644
--- a/lightning/src/util/test_utils.rs
+++ b/lightning/src/util/test_utils.rs
@@ -1698,7 +1698,7 @@ impl TestLogger {
impl Logger for TestLogger {
fn log(&self, record: Record) {
- let s = format!("{:<6} {}", self.id, record);
+ let s = format!("{:<2} {}", self.id, record);
#[cfg(ldk_bench)]
{
// When benchmarking, we don't actually want to print logs, but we do want to format| entry.insert(channel); | ||
| } else { | ||
| log_trace!(logger, | ||
| "Preferring counterparty {} channel {} (SCID {:?}, {} msats) over {} (SCID {:?}, {} msats) for invoice route hints", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word "over" got deleted, may need to tweak the log slightly to keep the original meaning as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted these two log lines. As they are making a comparison, it may be a bit weird to rely on the structured field only.
In some tests, the nodes are called 'alice' and 'bob', so we'd need to change that to 'a' and 'b' perhaps? Maybe just one character is also sufficient. Starting everyline with |
Previously, log messages often included the channel ID both in the message text and in the structured `channel_id` field. This led to redundant information and made it difficult to quickly identify which log lines pertain to a given channel, as the ID could appear in different positions or sometimes not at all. This change removes the channel ID from the message in all cases where it is already present in the structured field. A test run was used to verify that the structured field always appeared in these log calls. Some exceptions remain—for example, calls where the structured field contains a temporary channel ID and the message contains the final ID were left unchanged.
Since most log messages no longer include the channel ID in their text, this commit updates the test logger to output the structured channel ID instead. The ID is truncated for readability. Similarly peer id and payment hash are logged. Co-authored-by: Matt Corallo <[email protected]>
73ea256 to
e069743
Compare
This PR improves channel ID logging consistency and clarity.
Removes redundant channel ID text from log messages where the ID is
already included as a structured field. This reduces duplication and makes
it easier to filter logs by channel.
Updates the test logger to display the structured channel ID instead of
relying on message text. The logged ID is truncated for readability.
Also log peer id and payment hash as structured fields. Log message de-duplication is left for a follow up.
Together, these changes standardize how channel IDs appear in logs and make
them easier to parse and analyze.
Example output: